package com.fenqing.leetcode.code.t0_200.t0_100;

import com.fenqing.annotations.Execute;
import com.fenqing.bean.TreeNode;
import com.fenqing.core.Topic;

import java.util.ArrayList;
import java.util.List;

public class Topic094 extends Topic {

    /**
     * 构造器
     *
     * @param input 输入
     */
    public Topic094(String input) {
        super(input);
    }

    @Execute
    public List<Integer> inorderTraversal(TreeNode root) {
        List<Integer> result = new ArrayList<>();
        inorderTraversal(root, result);
        return result;
    }

    public void inorderTraversal(TreeNode root, List<Integer> list) {
        if (root == null) {
            return;
        }
        inorderTraversal(root.left, list);
        list.add(root.val);
        inorderTraversal(root.right, list);
    }

    public static void main(String[] args) {
        Topic094 topic94 = new Topic094("""
                [1,null,2,3]
                """);
        List<Integer> run = topic94.run();
        System.out.println(run);
    }
}
